﻿<Page 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:m="clr-namespace:Modelica.Annotations;assembly=ModelicaBase"
    xmlns:lib="clr-namespace:DrawToolsLib;assembly=DrawToolsLib"
    xmlns:util="clr-namespace:Utilities;assembly=Utilities"
    xmlns:libconvert="clr-namespace:Petzold.Converters;assembly=Utilities"
    xmlns:might="clr-namespace:DrawTools"
    Title="Might"
    MinWidth="800"
    MinHeight="640"
    x:Class="DrawTools.Page1" Background="#FF1E1E1E" x:Name="MainPage"
    ShowsNavigationUI="False" 
>   
    <Page.Resources>
        <Style TargetType="{x:Type TabItem}">
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="FontSize" Value="11"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabItem}">
                        <Grid>
                            <Border 
        		                x:Name="Border"
        		                CornerRadius="4,4,0,0"
        		                 Height="16" Margin="0,0,2,0">
                                <ContentPresenter x:Name="ContentSite"
        			                VerticalAlignment="Center"
        			                ContentSource="Header"
        			                Margin="6,0,6,0" HorizontalAlignment="Left"/>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter TargetName="Border" 
                                    Property="Background" Value="#FF595959" />
                            </Trigger>
                            <Trigger Property="IsSelected" Value="False">
                                <Setter TargetName="Border" 
                                    Property="Background" Value="#FF363636" />
                            </Trigger>
                            <Trigger Property="TabStripPlacement" Value="Bottom">
                                <Setter TargetName="Border" 
                                    Property="CornerRadius" Value="0,0,4,4" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="{x:Type ToolBar}">
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="#FFC8C8C8" Offset="0"/>
                        <GradientStop Color="#FF979797" Offset="0.5"/>
                        <GradientStop Color="#FF424242" Offset="1"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="{x:Type ToolBarTray}">
            <Setter Property="Background" Value="#FF515151"/>
        </Style>
        
        <!-- Converts tooltype to bool for checking controls -->
        <lib:ToolTypeConverter x:Key="convToolType"/>
        <!-- Converts tooltype to bool for checking controls -->
        <might:TabItemToList x:Key="convTabItem"/>
    </Page.Resources>

    <Page.CommandBindings>
        <CommandBinding Command="ApplicationCommands.New" Executed="NewCommand" />
        <CommandBinding Command="ApplicationCommands.Open" Executed="OpenCommand" />
        <CommandBinding Command="ApplicationCommands.Save" Executed="SaveCommand" CanExecute="CanExecuteSaveCommand" />
        <CommandBinding Command="ApplicationCommands.SaveAs" Executed="SaveAsCommand" />
    </Page.CommandBindings>
    
    <DockPanel x:Name="LayoutRoot" Margin="0,0,0,5">        

        <!-- Upper menu -->
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="File" >
                <MenuItem Command="New"/>
                <MenuItem Command="Open"/>
                <Separator/>
                <MenuItem Command="Save"/>
                <MenuItem Command="SaveAs"/>
            </MenuItem>
        </Menu>

        <!-- ToolBar -->
        <ToolBarTray x:Name="MainToolBar" DockPanel.Dock="Top">
            <!-- Icons - open,save etc. -->
            <ToolBar x:Name="MainToolbar">
                <Button Cursor="Hand" Command="New" ToolTip="New file">
                	<Image Source="Images/doc_24_hot.ico" Stretch="None" />
                </Button>
                <Button Cursor="Hand" Command="Open" ToolTip="Open file" Name="openBtn">
                	<Image Source="Images/filesystem_24_hot.ico" Stretch="None" />
                </Button>
                <Button Cursor="Hand" Command="Save" ToolTip="Save file" Name="saveBtn">
                	<Image Source="Images/save_24_dis.ico" Stretch="None" />
                </Button>
                <Separator/>
                <Button Cursor="Hand" IsEnabled="False" >
                    <Image Source="Images/copyup_24_dis.ico" Stretch="None"/>
                </Button>
                <Button Cursor="Hand" IsEnabled="False" >
                    <Image Source="Images/cut_24_dis.ico" Stretch="None"/>
                </Button>
                <Button Cursor="Hand" IsEnabled="False" >
                    <Image Source="Images/paste_24_dis.ico" Stretch="None"/>
                </Button>
                <Separator/>
                <Button Cursor="Hand" IsEnabled="False" >
                    <Image Source="Images/zoom_24_dis.ico" Stretch="None"/>
                </Button>
                <Button Cursor="Hand" IsEnabled="False" >
                    <Image Source="Images/print_24_dis.ico" Stretch="None"/>
                </Button>
                <Separator/>
                <Button Cursor="Hand" IsEnabled="False" >
                    <TextBlock Margin="5,0,5,0" Text="Full Screen"/>
                </Button>
                <Button x:Name="hideBtn" Cursor="Hand" Click="hideAllPanels" >
                    <TextBlock  Margin="5,0,5,0" Text="Hide all panels" x:Name="hideBtnTxt" />
                </Button>
            </ToolBar>
            <ToolBar x:Name="EditorToolbar" >
                <ToggleButton x:Name="buttonToolPointer"  ToolTip="Pointer" Tag="Pointer" Checked="Tool_Checked" >
                    <Image Source="Images/PointerHS.png"/>
                </ToggleButton>
                <ToggleButton x:Name="buttonToolRectangle" ToolTip="Rectangle" Tag="Rectangle" Checked="Tool_Checked">
    				<Image Source="Images/rectangle.png"/>
                </ToggleButton>
                <ToggleButton x:Name="buttonToolEllipse" ToolTip="Ellipse" Tag="Ellipse" Checked="Tool_Checked">
    				<Image Source="Images/ellipse.png"/>
                </ToggleButton>
                <ToggleButton x:Name="buttonToolLine" ToolTip="Line" Tag="PolyLine" Checked="Tool_Checked">
    				<Image Source="Images/line.png"/>
                </ToggleButton>
                <ToggleButton x:Name="buttonToolPencil" ToolTip="Pencil" Tag="Polygon" Checked="Tool_Checked">
    				<Image Source="Images/pencil.png"/>
                </ToggleButton>
                <ToggleButton x:Name="buttonToolText" ToolTip="Text" Tag="Text" Checked="Tool_Checked">
    				<Image Source="Images/Text.png"/>
                </ToggleButton>
                <Separator/>

                <Button Command="ApplicationCommands.Undo"  ToolTip="Undo">
                    <Image Source="Images/Edit_UndoHS.png" />
                </Button>
                <Button Command="ApplicationCommands.Redo"  ToolTip="Redo">
                    <Image Source="Images/Edit_RedoHS.png"/>
                </Button>

            </ToolBar>
        </ToolBarTray>

        <StatusBar DockPanel.Dock="Bottom" >
            <StatusBarItem>
                <TextBlock>Ready</TextBlock>
            </StatusBarItem>
        </StatusBar>        
        
        <!-- Work area -->
        <Grid Name="workArea" DockPanel.Dock="Top" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="23" Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition MinWidth="50"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition MinWidth="23" Width="Auto"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            
            
            <!-- left panel -->
            <Expander Grid.Column="0" ExpandDirection="Right" IsExpanded="True" Name="leftExpander" Collapsed="Left_Expander_Collapsed" Expanded="Left_Expander_Expanded">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition></RowDefinition>
                    </Grid.RowDefinitions>
                    <TabControl Background="#FF313131" Foreground="#FFCCCCCC" Grid.Row="0" Width="Auto" Height="Auto" >
                        <TabItem Header="TreeView" >
                            <TreeView Name="modelStructureTreeView" Background="#FF313131" Foreground="#FFCCCCCC" Width="Auto" Height="Auto"></TreeView>
                        </TabItem>
                    </TabControl>
                    <GridSplitter Grid.Row="1" Height="3" VerticalAlignment="Center" HorizontalAlignment="Stretch" ShowsPreview="False"></GridSplitter>
                    <ListBox Background="#FF313131" Foreground="#FFCCCCCC" Grid.Row="2" IsSynchronizedWithCurrentItem="True" MinWidth="150">
                        <ListBoxItem Content="Icon 1" Tag="0" MouseDoubleClick="ListBoxItem_MouseDoubleClick"/>
                        <ListBoxItem Content="Icon 2" Tag="1" MouseDoubleClick="ListBoxItem_MouseDoubleClick"/>
                        <ListBoxItem Content="Icon 3" Tag="2" MouseDoubleClick="ListBoxItem_MouseDoubleClick"/>
                    </ListBox>
                </Grid>
            </Expander>

            <!-- Splitter -->               
            <GridSplitter Grid.Column="1" Width="3" HorizontalAlignment="Center" VerticalAlignment="Stretch" ShowsPreview="False" Name="leftSplitter"></GridSplitter> 

            <!-- Model editor and bottom menu -->
            <DockPanel Grid.Column="2" LastChildFill="True" SnapsToDevicePixels="True">
                
                <Popup Name="OpenFileDialog" StaysOpen="True" Placement="Center" MinWidth="200" MaxWidth="600">
                    <Border BorderBrush="Beige" BorderThickness="2" Background="White">
                        <StackPanel Name="PopUpStackPanel" Margin="5" Background="White">
                            <TextBlock Margin="10" TextWrapping="Wrap">Otevřít soubor...</TextBlock>
                            <ListBox Name="FilesForOpenListBox" MaxHeight="400" ></ListBox>
                            <DockPanel Margin="0,10,0,0" LastChildFill="False">
                                <Button Name="OpenFileOkBtn" MinWidth="50" Click="OpenFileOkBtn_Click">OK</Button>
                                <Button Name="OpenFileCancelBtn" MinWidth="50" DockPanel.Dock="Right" Click="OpenFileCancelBtn_Click">Cancel</Button>
                            </DockPanel>
                        </StackPanel>
                    </Border>
                </Popup>                               
                
                <!-- Bottom menu -->
                <Expander Header="OMC Command" Foreground="#FFCCCCCC" DockPanel.Dock="Bottom" ExpandDirection="Up" Name="downExpander" IsExpanded="False">
                    <StackPanel Orientation="Vertical">
                        <TextBox TextWrapping="Wrap" Height="200" Background="#FF313131" Foreground="#FFCCCCCC" IsReadOnly="True" Name="omcResultTxt" VerticalScrollBarVisibility="Auto" />
                        <TextBox TextWrapping="Wrap" Background="#FF313131" Foreground="#FFCCCCCC" Name="omcRequestTxt" ToolTip="Type OMC Command here" KeyUp="omcRequestTxtKeyUp" />
                    </StackPanel>
                </Expander>
                
                <!-- Place for editing panels -->
                <TabControl Background="#00000000" x:Name="TabPanel" BorderBrush="#FF000000"></TabControl>                                               
                
            </DockPanel>

            <!-- Splitter -->
            <GridSplitter Grid.Column="3" Width="3" HorizontalAlignment="Center" VerticalAlignment="Stretch" ShowsPreview="False" Name="rightSplitter"></GridSplitter>

            <!-- right panel -->
            <Expander Grid.Column="4" Header="" ExpandDirection="Left" IsExpanded="True" Name="rightExpander" Collapsed="Right_Expander_Collapsed" Expanded="Right_Expander_Expanded">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition></RowDefinition>
                    </Grid.RowDefinitions>                    
                    <GridSplitter Grid.Row="1" Height="3" VerticalAlignment="Center" HorizontalAlignment="Stretch" ShowsPreview="False"></GridSplitter>
                    <TabControl Background="#FF313131" Foreground="#FFCCCCCC" Grid.Row="2" Width="Auto" Height="Auto">
                        <TabItem Header="Members">
                        	<ListBox x:Name="MembersBox" IsSynchronizedWithCurrentItem="True" Background="{x:Null}" 
                                ItemsSource="{Binding ElementName=TabPanel, Path=(SelectedItem as TabItem).(Content as IconEditor).Mclass.Graphics}" Foreground="#FFFFFFFF"/>
                        </TabItem>
                        <TabItem Header="Attributes"></TabItem>
                        <TabItem Header="Anotation"></TabItem>
                        <TabItem Header="Param"></TabItem>
                    </TabControl>
                    <lib:EllipseControl />
                </Grid>
            </Expander>

        </Grid>

    </DockPanel>
    
</Page>
